<template>
  <el-container>
    <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
      <el-menu :default-openeds="['1', '3']">
        <el-submenu index="1">
          <template slot="title">博客管理</template>
          <el-menu-item-group>
            <el-menu-item index="1-1" @click="open('blogs')"
              >所有博客</el-menu-item
            >
          </el-menu-item-group>
        </el-submenu>
      </el-menu>
    </el-aside>
  <el-container>
    <el-header
      >当前用户:<span style="color:#409EFF">{{loginUser}}</span>
      <div>
        <el-button @click="logout()"  type="danger"> <i class="el-icon-switch-button"></i>退出</el-button>
      </div></el-header
    >
    <!--进行路由跳转-->
    <el-main>
      <router-view>展示</router-view>
    </el-main>
  </el-container>
  </el-container>
</template>
<script>
import request from "@/api/request.js";
export default {
  data(){
    return{
      loginUser:localStorage.getItem("username")
    }
  },
  methods: {
    logout(){
      request.get("/logout").then((res)=>{
        if(res.data.data==200){
          localStorage.removeItem("token")
           this.$router.push({ name: "login" });
        }
      })
    },
    open(name) {
      this.$router.push({name});
    },
  },
};
</script>

<style scoped>
.el-container {
  height: 100%;
}

.el-header {
  margin-bottom: 20px;
  background: #e9eef3;
}

.el-footer {
  line-height: 60px;
}

.el-aside {
  background-color: #191a22;
  color: var(--el-text-color-primary);
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #fcfcfc;
  color: var(--el-text-color-primary);
}
</style>
